package com.study.mina;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

/**
 * Description:
 * User: 27010
 * DateTime: 2018/5/13 11:30
 */
public class SimpleClientHandler extends IoHandlerAdapter {
    @Override
    public void messageReceived(IoSession session, Object message) throws Exception {
        Thread.sleep(1000);

        session.write("client received num is : " + message.toString() + ", request next num");
    }

     /**
     * 当一个客户端连接进入时
     */
    @Override
    public void sessionOpened(IoSession session) throws Exception {

        System.out.println("create connection to server :" + session.getRemoteAddress());
        session.write("client started");
        session.write("Hello World!");
    }
}
